import axios from 'axios';

// 团队列表-人员信息
export type UserRecord = {
  id?: string;
  name?: string;
  username?: string;
  role?: number;
};

// 团队列表-团队信息
export interface TeamRecord {
  id?: string;
  name: string;
  projectId: string;
  color: string;
  role: number;
  count: number;
  teamUsers?: Array<UserRecord>;
  userIds?: string; // 用于选人组件的临时字段
  isShowColor?: boolean; // 是否显示修改颜色弹窗
  createBy?: string;
  createDate?: string;
  updateBy?: string;
  updateDate?: string;
  deleteFlag?: number;
}

// 分页查询参数
export interface TeamSearchParams {
  pageNo: number;
  pageSize: number;
  projectId: string;
  name?: string;
}

// 查询团队列表
export function queryTeamList(params: TeamSearchParams) {
  return axios.get('/cde-collaboration/team/list', {
    params,
  });
}

// 查询团队详情
export function queryTeamDetail(params: object) {
  return axios.get('/cde-collaboration/team/detail', {
    params,
  });
}

// 新增团队
export function saveTeam(data: TeamRecord) {
  return axios.post('/cde-collaboration/team/save', data);
}

// 编辑团队
export function updateTeam(data: TeamRecord) {
  return axios.post('/cde-collaboration/team/update', data);
}
